<?php
/**
 * Created by PhpStorm.
 * User: xujiang
 * Date: 2017/9/23
 * Time: 20:00
 */
function my_callback_function(){
    echo "hello world".PHP_EOL;
}

class Myclass {
    static function myCallbackMethod(){
        echo "Hello World2!".PHP_EOL;
    }
}

call_user_func('my_callback_function');  //直接调用my_callback_function函数实现callback;
call_user_func(array('MyClass','myCallbackMethod'));

$obj = new Myclass();

call_user_func(array($obj,'myCallbackMethod'));

call_user_func('MyClass::myCallbackMethod');

class A {
    public static function who() {
        echo "A\n";
    }
}

class B extends A {
    public static function who() {
        echo "B\n";
    }
}

call_user_func(array('B', 'parent::who')); // A

class C {
    public function __invoke($name) {
        echo 'Hello ', $name, "\n";
    }
}

$c = new C();
call_user_func($c, 'PHP!');


